cmake_minimum_required(VERSION 3.22)


set(CATLOG_ROOT_DIR  ${catlog_DIR}/../src)


if (CMAKE_SYSTEM_NAME MATCHES "Linux")
    message(STATUS "current platform: Linux ")
    add_definitions(-DCATLOG_PLATFORM_LINUX)
    file(GLOB_RECURSE CATLOG_SRC
            ${CATLOG_ROOT_DIR}/catlog.c
            ${CATLOG_ROOT_DIR}/xprintf.c
            ${CATLOG_ROOT_DIR}/catlog_port_linux.c
            )

elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
    message(STATUS "current platform: Windows")
    add_definitions(-DCATLOG_PLATFORM_WIN32)
    file(GLOB_RECURSE CATLOG_SRC
            ${CATLOG_ROOT_DIR}/catlog.c
            ${CATLOG_ROOT_DIR}/xprintf.c
            ${CATLOG_ROOT_DIR}/catlog_port_win32.c
            )
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
    message(STATUS "current platform: FreeBSD")
    add_definitions(-DCATLOG_PLATFORM_FREEBSD)
    file(GLOB_RECURSE CATLOG_SRC
            ${CATLOG_ROOT_DIR}/catlog.c
            ${CATLOG_ROOT_DIR}/xprintf.c
            ${CATLOG_ROOT_DIR}/catlog_port_linux.c
            )
else ()
    message(STATUS "current platform: RTOS")
    add_definitions(-DCATLOG_USE_XPRITF=1)
    add_definitions(-DCATLOG_BUFFER_STATIC=1)
    add_definitions(-DCATLOG_PLATFORM_RTOS)
    file(GLOB_RECURSE CATLOG_SRC
            ${CATLOG_ROOT_DIR}/catlog.c
            ${CATLOG_ROOT_DIR}/xprintf.c
            ${CATLOG_ROOT_DIR}/catlog_port_rtos.c
            )
    message("catlog src:${CATLOG_SRC}")
endif (CMAKE_SYSTEM_NAME MATCHES "Linux")

set(catlog_INCLUDE_DIR ${catlog_DIR}/../src)
include_directories(${catlog_INCLUDE_DIR})






